import {ModalForm, ProFormText} from "@ant-design/pro-components";
import React from "react";
import {addPageSqlConfig} from "@/services/wms-dev-tool/business-page-list";
import {useRequest} from "@@/plugin-request";

const SqlConfigAddForm = (props: any) => {
    const {run} = useRequest(addPageSqlConfig, {
        manual: true,
        onSuccess: () => {
            props.handleAddFormOpen(false);
            props.ok()
        }
    })
    return (
        <ModalForm
            initialValues={{
                name: '',
                code: ''
            }}
            modalProps={{
                destroyOnClose: true
            }}
            title={<span>新增SQL语句</span>}
            width="400px"
            open={props.addFormOpen}
            onOpenChange={props.handleAddFormOpen}
            onFinish={async (params: API.PageSqlConfig) => {
                params.pageId = props.payload.pageId
                run(params);
            }}
        >
            <ProFormText
                rules={[
                    {
                        required: true,
                        message: (
                            <span>编码是必填项</span>
                        ),
                    },
                ]}
                width="md"
                label={<span>编码</span>}
                placeholder={"请输入编码"}
                name="code"/>
            <ProFormText
                rules={[
                    {
                        required: true,
                        message: (
                            <span>描述信息是必填项</span>
                        ),
                    },
                ]}
                placeholder={"请输入描述信息"}
                label={<span>描述信息</span>}
                width="md"
                name="description"
            />
        </ModalForm>
    )
}
export default SqlConfigAddForm
